/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package Outils;

import java.net.MalformedURLException;
import java.rmi.Naming;
import java.rmi.NotBoundException;
import java.rmi.RemoteException;
import java.util.ArrayList;
import java.util.List;
import server.Monitoring;
import server.ServerHealth;
import server.Task;

/**
 *
 * @author smng2095
 */
public class LiaisonRMI {
   private String serveur, service;
   private ServerHealth monitor;
    
    public LiaisonRMI(String serveur, String service) throws RemoteException, NotBoundException, MalformedURLException {
	this.serveur = serveur;
	this.service = service;
	
	monitor = ( (Monitoring) Naming.lookup("//"+serveur+"/"+service)).getServerHealth();

    }
    
    public int getCpuLoad(){
    int r =0;
    r= monitor.getCpuLoad();
    return r;
    }
    
    public int getMemory(){
    int r =0;
    r = monitor.getMemory();
    return r ;
    }
    
    public Task getTask(int index){
	Task r = null;
	if(!(index <= monitor.getTasks().size()) | (index >= 0)) 
	    r = monitor.getTasks().get(index);
	return r ;
    }
    public List<Task> getArrayTask(){
	List<Task> r = null;
	r= monitor.getTasks();
	return r ;
    }
    
}
